@extends('layouts.default')
@section('content')

    <div class="card mt-4">
        <div class="card-header">
            <div class="text-center">
                <h1>{{$user->name}}</h1>
                <a href="{{route('follow.following',$user)}}" class="btn btn-info">关注: {{$user->following()->count()}}</a>
                <a href="{{route('follow.follow',$user)}}" class="btn btn-info">粉丝: {{$user -> follow() -> count()}}</a>
                @auth
                    <a href="{{route('user.follow',$user)}}" class="btn btn-success">{{$follow}} </a>
                @endauth
            </div>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th width="100px">编号</th>
                    <th>博文</th>
                    <th width="200px">发表时间</th>
                    <th width="200px">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($blogs as $blog)
                    <tr>
                        <td scope="row">{{$blog -> id}}</td>
                        <td>{{$blog -> content}}</td>
                        <td>{{$blog -> created_at }}</td>
                        <td>
                            @can('delete',$blog)
                                <form action="{{route('blog.destroy',$blog)}}" method="post">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="btn btn-danger">删除</button>
                                </form>
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="card-footer text-muted">
            {{$blogs -> links()}}
        </div>
    </div>

@endsection
